import http from '@/utils/http'

export const Login = (data) => {
	return http.post('integration/customer/token', data);
}

//获取商品渲染信息的api
export function productRender(data) {
	return http.get('products-render-info', data);
}
export function categories() {
  return http.get('categories');
}
// 允许客户或来宾用户为匿名客户创建空购物车和报价
export function guestCarts() {
  return http.post('guest-carts')
}
// 添加/更新指定的购物车项目。
export function add_card(url, data) {
  return http.post(`guest-carts/${url}/items`, data, {type: 'all/V1'});
}
// 获取AdminToken
export function integrationToken(data) {
  return http.post(`integration/admin/token`, data);
}
// 创建客户账号
export function customers(data, Authorization) {
  return http.post(`customers`, data, {Authorization: Authorization});
}
//根据token获取用户信息（主要是customerID)
export function customersMe(Authorization) {
	return http.get(`customers/me`, undefined, {Authorization: Authorization});
}
//获取指定目录id的商品
export function products(data) {
	return http.get(`products`, data);
}
//获取指定sku的商品媒体（图片）信息
export function productsSku(sku) {
	return http.get(`products/${sku}/media`);
}
//删除购物车中指定ItemId的项目，比如删除itemId为4的购物车项目
export function cartDelete(code, id) {
	return http.del(`guest-carts/${code}/items/${id}`, {});
}
//为当前用户创建一个购物车
export function cartsMine(data, Authorization) {
	return http.post(`carts/mine`, data , {Authorization: Authorization});
}
//添加商品到购物车
export function cartsMineItems(data, Authorization) {
	return http.post(`carts/mine/items`, data , {Authorization: Authorization});
}
//获取商店的所有国家和地区信息
export function getCountries() {
	return http.get(`directory/countries`);
}
//获取地区信息
export function getCity(countryId) {
	return http.get(`directory/countries/${countryId}`);
}
//根据地址id获取运输方式数据及运费
export function cartsPrice(data, Authorization) {
	return http.post(`carts/mine/estimate-shipping-methods-by-address-id`, data, {Authorization: Authorization});
}